#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
// priority_queue<int, vector<int>, less<int>> pq;

void solve() {
    int n, m, d;
    cin >> n >> m >> d;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    int p = 1, t = 0;
    int ans = 0;
    for(int i = 0; i < n; i++, p++) {
        int x; cin >> x;
        if(x > 0){
            t += x;
            ans = max(ans, t - p * d);
        }
    }
    cout << ans << endl;
}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}